<?php
/**
* @version		1.0 : view.html.php marum56
* @package		Joomla
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

/**
 * HTML View class for the Users component
 *
 * @static
 * @package		Joomla
 * @subpackage	Users
 * @since 1.0
 */
class UsersViewUser extends JView
{
	function display($tpl = null)
	{       
		$me = JFactory::getUser();
		$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
		$edit = JRequest::getVar('edit',true);
		
		JArrayHelper::toInteger($cid, array(0));

		$db =& JFactory::getDBO();
		
		if($edit) {
			$user =& JUser::getInstance( $cid[0] );
			
			jimport('joomla.user.helper');
			// Tworzy dodatkowe pole ozn. pierwsza rejestracje w systemie usera
			$user->pierwszaRejest = JUserHelper::getUserPierwszaRej($user->get('pesel'));
		} 
		else {
			$user =& JUser::getInstance();
		}
		
		$acl =& JFactory::getACL();

		// Check for post data in the event that we are returning
		// from a unsuccessful attempt to save data
		$post = JRequest::get('post');
		if ( $post ) {
			$user->bind($post);
		}
	
		$gtree = $acl->get_group_children_tree( null, 'USERS', false );
		//Usunięcie z drzewa grupy pole "Administrator",
		// gdy "Zarzad" jest zalogowany
   	        if (strtolower($me->get('usertype')) == 'zarzad') {
   	        	array_pop ($gtree);
   	        }		
		$lists['gid'] 	= JHTML::_('select.genericlist',   $gtree, 'gid', 'size="10"', 'value', 'text', $user->get('gid') );

		// build the html select list
		$lists['block'] 	= JHTML::_('select.booleanlist',  'block', 'class="inputbox" size="1"', $user->get('block') );
		
		// build the html select list
		$lists['sendEmail'] = JHTML::_('select.booleanlist',  'sendEmail', 'class="inputbox" size="1"', $user->get('sendEmail') );

		$this->assignRef('me', 	$me);
		$this->assignRef('lists', $lists);
		$this->assignRef('user', $user);

		parent::display($tpl);
	}
}
